/* Class to represent the Functional Dependency */

import java.util.ArrayList;

public class FuncDep {
	private ArrayList<String> from;
	private ArrayList<String> to;

	public FuncDep(String fr, String t) {
		this.setFrom(fr);
		this.setTo(t);
	}

	public void addFrom(String fr) {
		this.from.add(fr);
	}

	public void removeFrom(String fr) {
		this.from.remove(fr);
	}

	public void addTo(String t) {
		this.to.add(t);
	}

	public void remove(String t) {
		this.to.remove(t);
	}

	public void setFrom(String fr) {
		this.from = new ArrayList<String>();

		String[] list = fr.trim().split(",");
		for (int i = 0; i < list.length; i++) {
			this.from.add(list[i].trim());
		}
	}

	public ArrayList<String> getFrom() {
		return this.from;
	}

	public void setTo(String t) {
		this.to = new ArrayList<String>();

		String[] list = t.trim().split(",");
		for (int i = 0; i < list.length; i++) {
			this.to.add(list[i].trim());
		}
	}

	public ArrayList<String> getTo() {
		return this.to;
	}

	public String toString() {
		String left = "";
		String right = "";

		for (int i = 0; i < this.from.size(); i++) {
			left += this.from.get(i) + " ";
		}

		for (int i = 0; i < this.to.size(); i++) {
			right += this.to.get(i) + " ";
		}

		return left + "-> " + right;
	}
}
